package com.dxx.cloud.admin.enums;

import com.dxx.cloud.admin.constant.CommonConst;

/**
 * @author duh
 * @create 2019/1/9 19:16

 **/
public enum ErrorEnum {
    ADD_FAILED("ADD_FAILED","添加数据失败"),
    UPDATE_FAILED("UPDATE_FAILED","修改数据失败"),
    USER_NOT_ALLOWED_LOGIN("USER_NOT_ALLOWED_LOGIN","用户暂未授权登录"),
    USER_NAME_OR_PASSWORD_INCORRECT("USER_NAME_OR_PASSWORD_INCORRECT","用户名或密码错误"),
    GOODS_ALREADY_EXIST("GOODS_ALREADY_EXIST","同名商品已存在"),
    GOODS_SIZE_NOT_FOUND("GOODS_SIZE_NOT_FOUND","未找到商品规格"),
    GOODS_SCAN_NOT_FOUND("GOODS_SCAN_NOT_FOUND","未找到扫码商品"),
    DEBT_MUST_HAS_ID_CARD("DEBT_MUST_HAS_ID_CARD","欠款操作前必须输入客户身份证"),
    DEBT_NOT_ENOUGH("DEBT_NOT_ENOUGH","欠款额度不足"),
    DEBT_SMALL_THEN_ZERO("DEBT_SMALL_THEN_ZERO","欠款金额不能小于0"),
    DEPOSIT_SMALL_THEN_ZERO("DEPOSIT_SMALL_THEN_ZERO","总存款金额不能小于0"),
    ORDER_NOT_OWN("ORDER_NOT_OWN","当前订单不欠款"),
    ORDER_PAY_TYPE_NOT_SUPPORT("ORDER_PAY_TYPE_NOT_SUPPORT","不支持的支付方式"),
    ORDER_REPAY_TYPE_NOT_ALLOWED("ORDER_REPAY_TYPE_NOT_ALLOWED","不支持的还款方式"),
    REPAY_ORDER_NOT_CHOSEN("REPAY_ORDER_NOT_CHOSEN","请选择要还款的订单"),
    REPAY_ORDER_FAILED("REPAY_ORDER_FAILED","订单还款失败"),
    OWN_CUSTOMER_IS_NULL("OWN_CUSTOMER_IS_NULL","欠款用户为空"),
    MER_PASSWORD_IS_WRONG("MER_PASSWORD_IS_WRONG","商户密码错误"),
    SHOP_PASSWORD_IS_WRONG("SHOP_PASSWORD_IS_WRONG","门店密码错误"),
    UPDATE_SYS_CONFIG_FAILED("UPDATE_SYS_CONFIG_FAILED","更新系统配置失败"),
    UNIT_FLOOR_PRICE_VALUE("UNIT_FLOOR_PRICE_VALUE","商品%s规格%s底价是%s"),
    CUSTOMER_ALREADY_EXIST("CUSTOMER_ALREADY_EXIST","该用户已存在"),
    PAY_CONFIG_NOT_SET("PAY_CONFIG_NOT_SET","支付参数未设置"),
    ORDER_NOT_FIND_BY_OUT_TRADE_NO("ORDER_NOT_FIND_BY_OUT_TRADE_NO","根据outTradeNo未找到订单"),
    ORDER_NOT_EXIST("ORDER_NOT_EXIST","订单不存在"),
    CUSTOMER_DEPOSIT_NOT_EXIST("CUSTOMER_DEPOSIT_NOT_EXIST","客户存款不存在"),
    CUSTOMER_DEPOSIT_FAILED("CUSTOMER_DEPOSIT_FAILED","客户存款失败"),
    ORDER_REPAYED_CANOT_INVALID("ORDER_CANOT_INVALID","已销账订单不能作废"),
    INVENTORY_UPDATE_FAILED("INVENTORY_UPDATE_FAILED","修改库存失败"),
    DEVICE_NOT_SUPPORT("DEVICE_NOT_SUPPORT","该设备不支持"),
    PAY_ACCOUNT_MUST_BIG_THEN_ZERO("PAY_ACCOUNT_MUST_BIG_THEN_ZERO","支付金额必须大于0"),
    DUPLICATE_REQUEST_TOO_FAST("DUPLICATE_REQUEST_TOO_FAST","重复操作太快"),
    CUSTOMER_NAME_IS_EMPTY("CUSTOMER_NAME_IS_EMPTY","客户姓名为空"),
    CUSTOMER_CARD_IS_INVALID("CUSTOMER_CARD_IS_INVALID","客户身份证号有误"),
    CUSTOMER_NOT_EXIST("CUSTOMER_NOT_EXIST","客户未添加"),
    DISK_SN_CANNOT_NULL("DISK_SN_CANNOT_NULL","序列号不能为空"),
    ;
    private String code;
    private String message;

    private ErrorEnum(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getMessage(String lang){
        String message = getMessage();
        if(CommonConst.Lang.ENGLISH.equals(lang)){
            message = getCode().replace("_"," ");
        }
        return message;
    }
}
